using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMBlockController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region[Get-Data]
        public DataTable BindGirdTMBlock()
        {
            return cls.BindGridData("sp_TMBlock");
        }
        public DataTable BindGirdTMBlock_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMBlock_Detail_Edit","@Id", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMBlock(clsTMBlockProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Block_Alias", data.Block_Alias);
            cls.AddParameter("@Block_Name", data.Block_Name);
            cls.AddParameter("@Block_Name_E", data.Block_Name_E);
            cls.AddParameter("@Block_Name_C", data.Block_Name_C);
            cls.AddParameter("@Block_Note", data.Block_Note);
            cls.AddParameter("@Block_MaCha", data.MaCha);
            cls.ExecuteNonQuery("sp_TMBlock_Insert");
            return true;
        }
        public bool UpdateTMBlock(clsTMBlockProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Block_ID", data.Block_ID);
            cls.AddParameter("@Block_Alias", data.Block_Alias);
            cls.AddParameter("@Block_Name", data.Block_Name);
            cls.AddParameter("@Block_Name_E", data.Block_Name_E);
            cls.AddParameter("@Block_Name_C", data.Block_Name_C);
            cls.AddParameter("@Block_Note", data.Block_Note);
            cls.AddParameter("@Block_MaCha", data.MaCha);
            cls.ExecuteNonQuery("sp_TMBlock_Update");
            return true;
        }
        public bool DeleteTMBlock(int id)
        {
            cls.Delete("sp_TMBlock_Delete", "@Block_ID", id);
            return true;
        }
        public bool TMBlock_Check_Delete_TMDepartment(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMBlock_Check_Delete_TMDepartment", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMBlock_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}